<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/11/30
 * Time: 10:32
 */

namespace verdor\core;


class order
{
    protected $type ;
    protected $userid ;
    protected $r ;
    protected static $time;
    /*
     * 可被子类继承的构造函数
     */
    protected function __construct($type,$userid)
    {
        echo '<br />';
        echo 'order初始化';
        echo '<br />';
        /*
         * 对属性进行初始化
         */
        if($type == 0){
            $this->type = '普通订单';
        }elseif($type == 1){
            $this->type = '积分订单';
        }else{
            $this->type = '订单类别有误';
        }
        $this->userid = $userid;
        order::$time = date('Y-m-d H:i:s',time());
        echo '订单状态：'.$this->type;
        echo '<br />';
    }
    /*
     * 创建订单ID
     */
    protected function createOrder(){
        $this->r = rand(1000,9999);
        /*
         * 用户ID+四位随机数（子类调用时+订单类别）
         */
        echo '订单ID:'.$this->userid.$this->r;
    }
    /*
     * 静态方法
     * 打印支付结果
     */
    public static function pay(){
        echo '支付成功';
    }
    /*
     * 析构进行收尾
     */
    protected function __destruct()
    {
        // TODO: Implement __destruct() method.
        echo '<br />';
        echo 'order已清除';
        echo '<br />';
    }
}